package com.baizw.cultivation.module.admin.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baizw.cultivation.module.admin.entity.NoticeEntity;
import com.baizw.cultivation.module.admin.mapper.NoticeMapper;
import com.baizw.cultivation.module.admin.page.NoticeSearch;
import com.baizw.cultivation.module.admin.service.NoticeService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 公告Service实现
 *
 * @author 剧终1204
 * @version V1.0
 * @date 2020年07月27日 16:20
 */
@Slf4j
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, NoticeEntity> implements NoticeService {

    @Override
    public IPage<NoticeEntity> pageByParams(NoticeSearch<NoticeEntity> page) {
        LambdaQueryWrapper<NoticeEntity> queryWrapper = Wrappers.<NoticeEntity>lambdaQuery()
                .like(StrUtil.isNotBlank(page.getSearch()), NoticeEntity::getTitle, page.getSearch())
                .like(StrUtil.isNotBlank(page.getType()), NoticeEntity::getType, page.getType());
        return baseMapper.selectPage(page, queryWrapper);
    }

}
